<!DOCTYPE html>
<!-- saved from url=(0052)http://getbootstrap.com/docs/4.0/examples/dashboard/ -->
<html lang="en" xmlns:th="http://www.thymeleaf.org">

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>联系人管理-AddressBook</title>
    <!-- Bootstrap core CSS -->
    <link th:href="@{/css/bootstrap.min.css}" rel="stylesheet">

    <!-- Custom styles for this template -->
    <link th:href="@{/css/dashboard.css}" rel="stylesheet">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.4.1/dist/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
    <!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
    <script src="https://cdn.jsdelivr.net/npm/jquery@3.4.1/dist/jquery.slim.min.js" integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" crossorigin="anonymous"></script>
    <script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@4.4.1/dist/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script>

    <!-- Latest compiled and minified CSS -->
    <link rel="stylesheet" href="https://unpkg.com/bootstrap-table@1.15.3/dist/bootstrap-table.min.css">

    <!-- Latest compiled and minified JavaScript -->
    <script src="https://unpkg.com/bootstrap-table@1.15.3/dist/bootstrap-table.min.js"></script>
    <!-- Latest compiled and minified Locales -->
    <script src="https://unpkg.com/bootstrap-table@1.15.3/dist/locale/bootstrap-table-zh-CN.min.js"></script>

    <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.3/css/all.css" integrity="sha384-UHRtZLI+pbxtHCWp1t77Bi1L4ZtiqrqD80Kn4Z8NTSRyMA2Fd33n5dQ8lWUE00s/" crossorigin="anonymous">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.13.1/styles/default.min.css">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/hint.css/2.5.1/hint.min.css">


    <script>
        window.dataLayer = window.dataLayer || []
        function gtag() {window.dataLayer.push(arguments)}
        gtag('js', new Date())
        gtag('config', 'UA-132747866-1')
    </script>

    <style type="text/css">
        /* Chart.js */

        @-webkit-keyframes chartjs-render-animation {
            from {
                opacity: 0.99
            }
            to {
                opacity: 1
            }
        }

        @keyframes chartjs-render-animation {
            from {
                opacity: 0.99
            }
            to {
                opacity: 1
            }
        }

        .chartjs-render-monitor {
            -webkit-animation: chartjs-render-animation 0.001s;
            animation: chartjs-render-animation 0.001s;
        }
    </style>
</head>

<body>
    <div th:replace="~{commons/commons::topbar}"></div>

    <div class="container-fluid">
        <div class="row">
            <div th:replace="~{commons/commons::sidebar(active='list.html')}"></div>

            <main role="main" class="col-md-9 ml-sm-auto col-lg-10 pt-3 px-4">
                <h2>
                    <a class="btn btn-lg btn-success" th:href="@{/user/addPerson}">添加联系人</a>
                    <!--<input class="style_file_content" accept=".rar" type="file" id="upload_file_id"/>-->
                    <button  type="button" class="btn btn-lg btn-secondary" data-toggle="modal" data-target="#exampleModal">导入</button>
                    <div class="modal" tabindex="-1" role="dialog" id="exampleModal" >
                        <div class="modal-dialog modal-dialog-centered" role="document">
                            <div class="modal-content">
                                <div class="modal-header" style="height:50px">
                                    <h3 class="modal-title">导入文件选择</h3>
                                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                        <span aria-hidden="true">&times;</span>
                                    </button>
                                </div>
                                <div class="modal-body" style="height:100px">
                                    <p >仅支持.CSV、.vCard格式文件导入</p>
                                </div>
                                <form th:action="@{/user/upload}" method="post" enctype="multipart/form-data">

                                <div class="modal-footer" style="height:60px">

                                    <!--<button type="button" class="btn  btn-lg btn-primary">Save changes</button>-->
                                        <input type="file" class="btn-primary btn-lg"  name="multipartFile" id="multipartFile" style="width:180px" accept=".csv,.vCard" onchange="fileChange(this);">
                                        <input type="submit" class="btn-success btn-lg" value="上传文件" name="submit_upload" disabled>
                                        <button type="button" class="btn  btn-lg btn-secondary" data-dismiss="modal" style="width:50px">关闭</button>

                                </div>
                                </form>
                            </div>
                        </div>
                    </div>

                    <a class="btn btn-lg btn-light" th:href="@{/user/download}">导出</a>
                    <a class="btn btn-lg btn-danger" th:href="@{/user/toDeleteSelectedPerson}">删除</a>
                </h2>
                <div class="table-responsive">
                    <table class="table table-striped table-sm"
                           data-toggle="table"
                           data-pagination="false"
                           data-pagination-loop="false"
                           data-search="true"
                           data-show-pagination-switch="true"
                           data-show-columns="true"
                           data-page-number="1"
                           data-page-size="5"
                           data-page-list="[5,10,25]"
                           data-click-to-select="true"
                           data-striped="true"
                            >
                        <!--data-single-select="true"-->
                        <thead>
                        <tr>
                           <!-- <th>personId</th>-->
                            <th class="col-xs-1" data-field="state" data-checkbox="true"></th>
                            <th>Icon</th>
                            <th data-sortable="true">姓名</th>
                            <th data-sortable="true">手机</th>
                            <th data-sortable="true">电话</th>
                            <th data-sortable="true">微信</th>
                            <th data-sortable="true">QQ</th>
                            <th data-sortable="true">E-mail</th>
                            <th data-sortable="true">工作单位</th>
                            <th data-sortable="true">家庭住址</th>
                            <th data-sortable="true">邮编</th>
                            <th data-sortable="true">备注</th>
                            <th data-sortable="true">生日</th>
                            <th data-sortable="true">分组</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody>
                            <tr th:each="person:${personInfoList}">
                               <!-- <td th:text="${person.getPersonId()}"></td>-->
                                <td></td>
                                <td th:type="img" th:src="${person.getPersonIcon()}" width="30" height="30" ></td>
                                <td th:text="${person.getPersonName()}"></td>
                                <td th:text="${person.getPersonPhone1()}"></td>
                                <td th:text="${person.getPersonPhone2()}"></td>
                                <td th:text="${person.getPersonWechat()}"></td>
                                <td th:text="${person.getPersonQq()}"></td>
                                <td th:text="${person.getPersonMail()}"></td>
                                <td th:text="${person.getPersonCompany()}"></td>
                                <td th:text="${person.getPersonAddress()}"></td>
                                <td th:text="${person.getPersonPostcode()}"></td>
                                <td th:text="${person.getPersonRemark()}"></td>
                                <td th:text="${#dates.format(person.getPersonBirthday(),'yyyy-MM-dd')}"></td>
                                <td th:each="category:${categoryList}" th:if="${category.getCategoryId()}==${person.getCategoryId()}" th:text="${category.getCategoryName()}"></td>
                                <td>
                                    <a class="btn btn-sm btn-primary" th:href="@{/user/toChangePerson?personId=}+${person.getPersonId()}">编辑</a>
                                    <a class="btn btn-sm btn-danger" th:href="@{/user/toDeletePerson?personId=}+${person.getPersonId()}" onClick="return confirm('删除后将无法恢复,确定要删除?')">删除</a>
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </div>
            </main>
        </div>
    </div>

<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script type="text/javascript" src="asserts/js/jquery-3.2.1.slim.min.js"></script>
<script type="text/javascript" src="asserts/js/popper.min.js"></script>
<script type="text/javascript" src="asserts/js/bootstrap.min.js"></script>

<!-- Icons -->
<script type="text/javascript" src="asserts/js/feather.min.js"></script>
<script>
    feather.replace()
</script>

<!-- Graphs -->
<script type="text/javascript" src="asserts/js/Chart.min.js"></script>
<script>
    var ctx = document.getElementById("myChart");
    var myChart = new Chart(ctx, {
        type: 'line',
        data: {
            labels: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
            datasets: [{
                data: [15339, 21345, 18483, 24003, 23489, 24092, 12034],
                lineTension: 0,
                backgroundColor: 'transparent',
                borderColor: '#007bff',
                borderWidth: 4,
                pointBackgroundColor: '#007bff'
            }]
        },
        options: {
            scales: {
                yAxes: [{
                    ticks: {
                        beginAtZero: false
                    }
                }]
            },
            legend: {
                display: false,
            }
        }
    });
</script>

</body>
<script>
   /* multipartFile.onchange=*/
    function fileChange(target) {
    var fileName = document.all.multipartFile.value;
    var ext,idx;
    if(fileName == ''){
        document.all.submit_upload.disabled = true;
        alert(confirm('未选择文件,请选择文件！'));
        return;
    }else {
        idx = fileName.lastIndexOf('.');
        if(idx != -1){
            ext = fileName.substr(idx+1).toUpperCase();
            ext = ext.toLowerCase();
            if(ext!='csv'&& ext!='vcard'){
                document.all.submit_upload.disabled=true;
                alert(confirm('请选择.csv或。vCard格式文件！'));
                return;
            }
        }else {
            document.all.submit_upload.disabled=true;
            alert(confirm('请选择.csv或。vCard格式文件！'));
            return;
        }
    }
    var isIE = /msie/i.test(navigator.userAgent) && !window.opera;
    var fileSize = 0;
    if (isIE && !target.files){
        var filePath = target.value;
        var fileSystem = new ActiveXObject();
        var file = fileSystem.GetFile (filePath);
        fileSize = file.Size;
    } else {
        fileSize = target.files[0].size;
    }
    var size = fileSize / (1024*1024);

    if(size>20){
        document.all.submit_upload.disabled=true;
        alert(warn('文件过大,已超过20MB!'));
    }else{
        document.all.submit_upload.disabled=false;
    }

    }


</script>

</html>
